package Leetcode;

public class jump {
    public int jump(int[] nums) {
        int res = 0;
        int curStep = 0;
        int fastStep = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            fastStep = Math.max(fastStep, i + nums[i]);
            if (i == curStep){
                curStep = fastStep;
                res++;
            }
        }
        return res;
    }
}
